<template>
	<view class="RankList">
		<u-navbar title="排行榜" back-icon-color="#fff" :background="background" title-color="#fff"></u-navbar>
		<view class="u-page">
			<view class="content">
				<view class="banner">
					<view class="icon"></view>
				</view>
				<view class="listBox">
					<view class="listItem" v-for="(item, index) in RankList" :key="item.id" @click="goPlay(item, index)">
						<view class="left">
							<view class="rank">
								{{index + 1 >= 10 ? index + 1 : "0" + (index + 1)}}
							</view>
							<view class="detail">
								<view class="songTitle">
									{{item.musicName}}
								</view>
								<view class="author">
									{{item.singer}}
								</view>
							</view>
						</view>
						<view class="right">
							<u-icon name="arrow-" custom-prefix="custom-icon" color="#999"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from "vuex"
	export default {
		data() {
			return {
				background: {},
				textColor: "",
				RankList: [],
			}
		},
		computed: {
			...mapState({
				list:({config})=>config.tabBarList,
				commonColor: ({config})=>config.commonColor,
			})
		},
		methods: {
			...mapMutations({
				SET_List: "config/SET_List",
				SET_index: "config/SET_index",
			}),
			goPlay(item, index) {
				const List = this.RankList;
				this.SET_List(List);
				this.SET_index(index);
				this.$Router.push({
					name: 'player',
				})
			}
		},
		created() {
			this.background["backgroundColor"] = this.commonColor;
			this.textColor= this.commonColor;
			this.$http.post("/musicList.htm").then(res => {
				this.RankList = res.result;
			})
		}
	}
</script>

<style lang="less" scoped>
.RankList {
	display: flex;
	flex-direction: column;
	height: 100%;
	.u-page {
		flex: 1;
		// overflow: hidden;
		padding: 20rpx;
		.content {
			background-color: #fff;
			padding: 20rpx;
			.banner {
				background: url(../../static/img/hot.jpg) no-repeat;
				padding: 60rpx 0 30rpx 30rpx;
				border-radius: 10rpx;
				.icon {
					width: 284rpx;
					height: 134rpx;
					background: url(../../static/img/hotSong.png);
					background-size: 284rpx 134rpx;
				}
			}
			.listBox {
				.listItem {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 20rpx 0;
					.left {
						display: flex;
						align-items: center;
						.rank {
							font-size: 35rpx;
							color: #df3436;
						}
						.detail {
							padding-left: 20rpx;
							.songTitle {
								font-size: 30rpx;
								letter-spacing: 8rpx;
								padding: 10rpx 0;
							}
							.author {
								font-size: 20rpx;
								color: #666;
							}
						}
					}
					.right {
						font-size: 35rpx;
					}
				}
			}
		}
	}
}
</style>
